//
//  StrategyParser.m
//  ITrip
//
//  Created by dllo on 15/5/22.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "StrategyParser.h"

@implementation StrategyParser

+ (NSMutableArray *)getParser:(NSData *)data
{
    NSMutableArray *arrayData = [NSMutableArray array];
    NSMutableArray *arrayAsia = [NSMutableArray array];
    NSMutableArray *arrayEurope = [NSMutableArray array];
    NSMutableArray *arrayElse = [NSMutableArray array];
    NSArray *array = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
    for (NSDictionary *dic in array) {
        StrategyModel *model1 = [StrategyModel getModel];
        model1.category = [[dic objectForKey:@"category"] integerValue];
            NSArray *array1 = [dic objectForKey:@"destinations"];
            for (NSDictionary *dic1 in array1) {
                StrategyModel *model = [StrategyModel getModel];
                model.name_zh_cn = [dic1 objectForKey:@"name_zh_cn"];
                model.name_en = [dic1 objectForKey:@"name_en"];
                model.poi_count = [[dic1 objectForKey:@"poi_count"]integerValue];
                model.updated_at = [[dic1 objectForKey:@"updated_at"] integerValue];
                model.image = [dic1 objectForKey:@"image_url"];
                model.id = [[dic1 objectForKey:@"id"] integerValue];
//                NSLog(@"%ld", model.id);
                if (model1.category == 1) {
                    [arrayAsia addObject:model];

//                    NSLog(@"%@", model.name_zh_cn);

                } else if (model1.category == 2) {
                    [arrayEurope addObject:model];
                } else if (model1.category == 3) {
                    [arrayElse addObject:model];
                }
        }
    }
    [arrayData addObject:arrayAsia];
    [arrayData addObject:arrayEurope];
    [arrayData addObject:arrayElse];
    
    return arrayData;
}


    
@end